package org.chainsale.common;

import org.chainsale.bean.Practitioner;
import org.chainsale.bean.Rank;

public class PractitionerFactory {

	private static final int SHARE_DEFAULT = 21;
	private static final double xRat = 19000/69800;
	
	public static Practitioner create() {
		Practitioner p = new Practitioner();
		
		p.setId(IdGenerator.getNextId());
		p.setName("P"+p.getId());
		p.setShare(SHARE_DEFAULT);
		p.setRank(Rank.getRankByShare(SHARE_DEFAULT));
		p.addOutgoing(SHARE_DEFAULT * Info.getInstance().getMoneyPerShare() + 500);
		p.setSuperior(null);
		
		int xIncoming = 19000;
		if (p.getShare() != 21) {
			xIncoming = (int) xRat * p.getOutgoing();
		}
		p.addIncoming(xIncoming);
		
		p.getAllUIds().add(p.getId());
		
		return p;
	}
	
	public static Practitioner create(String name) {
		Practitioner p = create();
		
		p.setName(name);
		
		return p;
	}
	
}
